﻿using System;
using System.Collections.Generic;
using System.Linq;

using SharedGenomics.Domain;

namespace SharedGenomics.Workbench.PresentationModel
{
    public class ModelOptionsPTO : PresentationTransferObject
    {
        public bool Dominant { get; set; }
        public bool Allelic { get; set; }
        public bool Trend { get; set; }
        public bool Recessive { get; set; }
        public bool Genotypic { get; set; }

        public ModelOptionFlags SelectedModelOptions
        {
            get
            {
                ModelOptionFlags options = ModelOptionFlags.None;
                if (this.Allelic) options |= ModelOptionFlags.Alleleic;
                if (this.Dominant) options |= ModelOptionFlags.Dominant;
                if (this.Genotypic) options |= ModelOptionFlags.Genotypic;
                if (this.Recessive) options |= ModelOptionFlags.Recessive;
                if (this.Trend) options |= ModelOptionFlags.Trend;

                return options;
            }
        }

        protected override void Validate(SharedGenomics.Core.IValidationErrorCollection validationErrors)
        {
            base.Validate(validationErrors);

            if (this.SelectedModelOptions == ModelOptionFlags.None)
            {
                validationErrors.Add("At least one model option is required for PModel jobs", this, "SelectedModelOptions");
            }
        }
    }
}
